package com.credithc.signature.manager.config.upload;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

/**
 * @desc: 设置文件上传大小限制<br/>
 * @author: Jingbo Hu<br/>
 * @time：2019年09⽉11⽇<br/>
 * @version：v1.0.0<br>
 */
@Configuration
public class TomcatConfig {

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //  单个数据大小
        DataSize MaxFileSize = DataSize.ofMegabytes(100L);
        factory.setMaxFileSize(MaxFileSize);
        /// 总上传数据大小
        DataSize MaxRequestSize = DataSize.ofMegabytes(100L);
        factory.setMaxRequestSize(MaxRequestSize);
        return factory.createMultipartConfig();
    }
}
